

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Getting started &mdash; hrvanalysis 1.0.0 documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="API documentation" href="hrvanalysis.html" />
    <link rel="prev" title="Welcome to hrv-analysis documentation!" href="index.html" /> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> hrvanalysis
          

          
          </a>

          
            
            
              <div class="version">
                1.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Getting started</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#hrv-analysis">hrv-analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="#installation-prerequisites">Installation / Prerequisites</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#user-installation">User installation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dependencies">Dependencies</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#quick-examples">Quick examples</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#outliers-and-ectopic-beats-filtering-methods">Outliers and ectopic beats filtering methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="#features-calculation">Features calculation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#plot-functions">Plot functions</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="hrvanalysis.html">API documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial - Python examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="unittests.html">Hrv-analysis Unittests¶</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="references.html">References</a></li>
<li class="toctree-l1"><a class="reference internal" href="contribute.html">Contribute</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">hrvanalysis</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Getting started</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/readme.md.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="getting-started">
<span id="getting-started"></span><h1>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
<div class="section" id="hrv-analysis">
<span id="hrv-analysis"></span><h2>hrv-analysis<a class="headerlink" href="#hrv-analysis" title="Permalink to this headline">¶</a></h2>
<p><a class="reference external" href="https://badge.fury.io/py/hrv-analysis"><img alt="PyPI version" src="https://badge.fury.io/py/hrv-analysis.svg" /></a>
<a class="reference external" href="https://travis-ci.com/robinchampseix/hrvanalysis"><img alt="Build Status" src="https://travis-ci.com/robinchampseix/hrvanalysis.svg?branch=master" /></a>
<a class="reference external" href="https://codecov.io/gh/robinchampseix/hrvanalysis"><img alt="codecov" src="https://codecov.io/gh/robinchampseix/hrvanalysis/branch/master/graphs/badge.svg" /></a>
<a class="reference external" href="https://www.gnu.org/licenses/gpl-3.0"><img alt="License: GPL v3" src="https://img.shields.io/badge/License-GPL%20v3-blue.svg" /></a>
<a class="reference external" href="https://pepy.tech/project/hrv-analysis"><img alt="Downloads" src="https://pepy.tech/badge/hrv-analysis" /></a></p>
<p><strong>hrvanalysis</strong> is a Python module for Heart Rate Variability analysis of RR-intervals built on top of SciPy, AstroPy, Nolds and NumPy and distributed under the GPLv3 license.</p>
<p>The development of this library started in July 2018 as part of <a class="reference external" href="https://www.aura.healthcare">Aura Healthcare</a> project, in <a class="reference external" href="https://www.octo.com/fr">OCTO Technology</a> R&amp;D team and is maintained by Robin Champseix.</p>
<p><img alt="Plot image" src="_images/timeserie_distrib_plot.png" /></p>
</div>
<div class="section" id="installation-prerequisites">
<span id="installation-prerequisites"></span><h2>Installation / Prerequisites<a class="headerlink" href="#installation-prerequisites" title="Permalink to this headline">¶</a></h2>
<div class="section" id="user-installation">
<span id="user-installation"></span><h3>User installation<a class="headerlink" href="#user-installation" title="Permalink to this headline">¶</a></h3>
<p>The easiest way to install hrv-analysis is using <code class="docutils literal notranslate"><span class="pre">pip</span></code> :</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install hrv-analysis
</pre></div>
</div>
<p>you can also clone the repository:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/robinchampseix/hrvanalysis.git
$ python setup.py install
</pre></div>
</div>
</div>
<div class="section" id="dependencies">
<span id="dependencies"></span><h3>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h3>
<p>hrvanalysis requires the following:</p>
<ul class="simple">
<li>Python (&gt;= 3.5)</li>
<li>astropy &gt;= 3.0.4</li>
<li>future &gt;= 0.16.0</li>
<li>nolds &gt;= 0.4.1</li>
<li>numpy &gt;= 1.15.1</li>
<li>scipy &gt;= 1.1.0</li>
</ul>
</div>
</div>
<div class="section" id="quick-examples">
<span id="quick-examples"></span><h2>Quick examples<a class="headerlink" href="#quick-examples" title="Permalink to this headline">¶</a></h2>
<div class="section" id="outliers-and-ectopic-beats-filtering-methods">
<span id="outliers-and-ectopic-beats-filtering-methods"></span><h3>Outliers and ectopic beats filtering methods<a class="headerlink" href="#outliers-and-ectopic-beats-filtering-methods" title="Permalink to this headline">¶</a></h3>
<p>This package provides methods to remove outliers and ectopic beats from signal for further analysis. Those methods are useful to get Normal to Normal Interval (NN-intervals) from RR-intervals.
Please use this methods carefully as they might have a huge impact on features calculation.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">hrvanalysis</span> <span class="kn">import</span> <span class="n">remove_outliers</span><span class="p">,</span> <span class="n">remove_ectopic_beats</span><span class="p">,</span> <span class="n">interpolate_nan_values</span>

<span class="c1"># rr_intervals_list contains integer values of RR-interval</span>
<span class="n">rr_intervals_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">1050</span><span class="p">,</span> <span class="mi">1020</span><span class="p">,</span> <span class="mi">1080</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="mi">1100</span><span class="p">,</span> <span class="mi">1110</span><span class="p">,</span> <span class="mi">1060</span><span class="p">]</span>

<span class="c1"># This remove outliers from signal</span>
<span class="n">rr_intervals_without_outliers</span> <span class="o">=</span> <span class="n">remove_outliers</span><span class="p">(</span><span class="n">rr_intervals</span><span class="o">=</span><span class="n">rr_intervals_list</span><span class="p">,</span>  
                                                <span class="n">low_rri</span><span class="o">=</span><span class="mi">300</span><span class="p">,</span> <span class="n">high_rri</span><span class="o">=</span><span class="mi">2000</span><span class="p">)</span>
<span class="c1"># This replace outliers nan values with linear interpolation</span>
<span class="n">interpolated_rr_intervals</span> <span class="o">=</span> <span class="n">interpolate_nan_values</span><span class="p">(</span><span class="n">rr_intervals</span><span class="o">=</span><span class="n">rr_intervals_without_outliers</span><span class="p">,</span> 
                                                   <span class="n">interpolation_method</span><span class="o">=</span><span class="s2">&quot;linear&quot;</span><span class="p">)</span>

<span class="c1"># This remove ectopic beats from signal</span>
<span class="n">nn_intervals_list</span> <span class="o">=</span> <span class="n">remove_ectopic_beats</span><span class="p">(</span><span class="n">rr_intervals</span><span class="o">=</span><span class="n">interpolated_rr_intervals</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s2">&quot;malik&quot;</span><span class="p">)</span>
<span class="c1"># This replace ectopic beats nan values with linear interpolation</span>
<span class="n">interpolated_nn_intervals</span> <span class="o">=</span> <span class="n">interpolate_nan_values</span><span class="p">(</span><span class="n">rr_intervals</span><span class="o">=</span><span class="n">nn_intervals_list</span><span class="p">)</span>
</pre></div>
</div>
<p>You can find how to use the following methods, references and more details in the <a class="reference external" href="https://robinchampseix.github.io/hrvanalysis/tutorial.html">documentation</a>:</p>
<ul class="simple">
<li>remove_outliers</li>
<li>remove_ectopic_beats</li>
</ul>
</div>
<div class="section" id="features-calculation">
<span id="features-calculation"></span><h3>Features calculation<a class="headerlink" href="#features-calculation" title="Permalink to this headline">¶</a></h3>
<p>There are 4 types of features you can get from NN Intervals:</p>
<blockquote>
<div>Time domain features : <strong>Mean_NNI, SDNN, SDSD, NN50, pNN50, NN20, pNN20, RMSSD, Median_NN, Range_NN, CVSD, CV_NNI, Mean_HR, Max_HR, Min_HR, STD_HR</strong></div></blockquote>
<blockquote>
<div>Geometrical domain features : <strong>Triangular_index, TINN</strong></div></blockquote>
<blockquote>
<div>Frequency domain features : <strong>LF, HF, VLF, LH/HF ratio, LFnu, HFnu, Total_Power</strong></div></blockquote>
<blockquote>
<div>Non Linear domain features : <strong>CSI, CVI, Modified_CSI, SD1, SD2, SD1/SD2 ratio, SampEn</strong></div></blockquote>
<p>As an exemple, what you can compute to get Time domain analysis is :</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">hrvanalysis</span> <span class="kn">import</span> <span class="n">get_time_domain_features</span>
 
 <span class="c1"># nn_intervals_list contains integer values of NN-interval</span>
<span class="n">nn_intervals_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">1050</span><span class="p">,</span> <span class="mi">1020</span><span class="p">,</span> <span class="mi">1080</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="mi">1100</span><span class="p">,</span> <span class="mi">1110</span><span class="p">,</span> <span class="mi">1060</span><span class="p">]</span>

<span class="n">time_domain_features</span> <span class="o">=</span> <span class="n">get_time_domain_features</span><span class="p">(</span><span class="n">nn_intervals_list</span><span class="p">)</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">time_domain_features</span>
<span class="p">{</span><span class="s1">&#39;mean_nni&#39;</span><span class="p">:</span> <span class="mf">718.248</span><span class="p">,</span>
 <span class="s1">&#39;sdnn&#39;</span><span class="p">:</span> <span class="mf">43.113</span><span class="p">,</span>
 <span class="s1">&#39;sdsd&#39;</span><span class="p">:</span> <span class="mf">19.519</span><span class="p">,</span>
 <span class="s1">&#39;nni_50&#39;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span>
 <span class="s1">&#39;pnni_50&#39;</span><span class="p">:</span> <span class="mf">2.4</span><span class="p">,</span>
 <span class="s1">&#39;nni_20&#39;</span><span class="p">:</span> <span class="mi">225</span><span class="p">,</span>
 <span class="s1">&#39;pnni_20&#39;</span><span class="p">:</span> <span class="mf">22.5</span><span class="p">,</span>
 <span class="s1">&#39;rmssd&#39;</span><span class="p">:</span> <span class="mf">19.519</span><span class="p">,</span>
 <span class="s1">&#39;median_nni&#39;</span><span class="p">:</span> <span class="mf">722.5</span><span class="p">,</span>
 <span class="s1">&#39;range_nni&#39;</span><span class="p">:</span> <span class="mi">249</span><span class="p">,</span>
 <span class="s1">&#39;cvsd&#39;</span><span class="p">:</span> <span class="mf">0.0272</span><span class="p">,</span>
 <span class="s1">&#39;cvnni&#39;</span><span class="p">:</span> <span class="mf">0.060</span><span class="p">,</span>
 <span class="s1">&#39;mean_hr&#39;</span><span class="p">:</span> <span class="mf">83.847</span><span class="p">,</span>
 <span class="s1">&#39;max_hr&#39;</span><span class="p">:</span> <span class="mf">101.694</span><span class="p">,</span>
 <span class="s1">&#39;min_hr&#39;</span><span class="p">:</span> <span class="mf">71.513</span><span class="p">,</span>
 <span class="s1">&#39;std_hr&#39;</span><span class="p">:</span> <span class="mf">5.196</span><span class="p">}</span>
</pre></div>
</div>
<p>You can find how to use the following methods, references and details about each feature in the <a class="reference external" href="https://robinchampseix.github.io/hrvanalysis/tutorial.html">documentation</a>:</p>
<ul class="simple">
<li>get_time_domain_features</li>
<li>get_geometrical_features</li>
<li>get_frequency_domain_features</li>
<li>get_csi_cvi_features</li>
<li>get_poincare_plot_features</li>
<li>get_sampen</li>
</ul>
</div>
<div class="section" id="plot-functions">
<span id="plot-functions"></span><h3>Plot functions<a class="headerlink" href="#plot-functions" title="Permalink to this headline">¶</a></h3>
<p>There are several plot functions that allow you to see, for example, the Power Spectral Density (PSD) for frequency domain features or Poincaré Plot for non linear domain features:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">hrvanalysis</span> <span class="kn">import</span> <span class="n">plot_psd</span>

<span class="c1"># nn_intervals_list contains integer values of NN-interval</span>
<span class="n">nn_intervals_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">1050</span><span class="p">,</span> <span class="mi">1020</span><span class="p">,</span> <span class="mi">1080</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="mi">1100</span><span class="p">,</span> <span class="mi">1110</span><span class="p">,</span> <span class="mi">1060</span><span class="p">]</span>

<span class="n">plot_psd</span><span class="p">(</span><span class="n">nn_intervals_list</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s2">&quot;welch&quot;</span><span class="p">)</span>
<span class="n">plot_distrib</span><span class="p">(</span><span class="n">nn_intervals_list</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s2">&quot;lomb&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p><img alt="Plot image" src="_images/psd_periodogram_plot.png" /></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">hrvanalysis</span> <span class="kn">import</span> <span class="n">plot_poincare</span>

<span class="c1"># nn_intervals_list contains integer values of NN-interval</span>
<span class="n">nn_intervals_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">1050</span><span class="p">,</span> <span class="mi">1020</span><span class="p">,</span> <span class="mi">1080</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="mi">1100</span><span class="p">,</span> <span class="mi">1110</span><span class="p">,</span> <span class="mi">1060</span><span class="p">]</span>

<span class="n">plot_poincare</span><span class="p">(</span><span class="n">nn_intervals_list</span><span class="p">)</span>
<span class="n">plot_poincare</span><span class="p">(</span><span class="n">nn_intervals_list</span><span class="p">,</span> <span class="n">plot_sd_features</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
<p><img alt="Plot image" src="_images/poincare_plot.png" /></p>
<p>You can find how to use methods and details in the <a class="reference external" href="https://robinchampseix.github.io/hrvanalysis/tutorial.html">documentation</a>:</p>
<ul class="simple">
<li>plot_distrib</li>
<li>plot_timeseries</li>
<li>plot_psd</li>
<li>plot_poincare</li>
</ul>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="hrvanalysis.html" class="btn btn-neutral float-right" title="API documentation" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="index.html" class="btn btn-neutral" title="Welcome to hrv-analysis documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Robin Champseix.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'1.0.0',
            LANGUAGE:'None',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="_static/jquery.js"></script>
      <script type="text/javascript" src="_static/underscore.js"></script>
      <script type="text/javascript" src="_static/doctools.js"></script>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

  

  <script type="text/javascript" src="_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>